<template>
	<view>
		<view class="top">
			<view v-if="res.status == 0">
				<view v-if="res.paytype == 3">
					货到付款，等待发货
				</view>
				<view v-else>
					等待付款
				</view>
			</view>
			<view v-else-if="res.status == 1">
				<text v-if="res.sendtype >0">部分商品已发货</text>
				<text v-else>买家已付款</text>
				<text v-if="res.ccard !=0&&res.ccard != null">(充值中)</text>
			</view>
			<view v-else-if="res.status == 2">
				<text>卖家已发货</text>
			</view>
			<view v-else-if="res.status == 3">
				<text>交易完成</text><text v-if="res.ccard !=0 &&res.ccard != null">(充值完成)</text>
			</view>
			<view v-else-if="res.static == -1">
				<text>交易关闭</text>
			</view>
			<view style="font-size: 24upx;" v-cloak>
				订单金额：{{res.goodsprice-res.tongduibao-res.jindou}}
			</view>
		</view>
		<view class="list">
			<view class="uni-list">
				<view v-if="res.express" class="uni-list-cell" hover-class="uni-list-cell-hover">
					<view class="uni-list-cell-navigate uni-navigate-right uni-media-list" @click="jump()">
						<view class="uni-media-list-logo" style="width: 40upx;">
							<image src="../../../static/orderadd.png" style="width: 32upx;height: 32upx;margin: 26upx auto;"></image>
						</view>
						<view class="uni-media-list-body">
							<view class="uni-media-list-text-top" style="font-size: 28upx;color: #f55;" v-cloak>{{res.express_step}}</view>
							<view class="uni-media-list-text-bottom uni-ellipsis" v-cloak>{{res.express_time}}</view>
						</view>
					</view>
				</view>
				<view class="uni-list-cell">
					<view class="uni-media-list">
						<view class="uni-media-list-logo" style="width: 40upx;">
							<image src="../../../static/dingwei.png" style="width: 32upx;height: 32upx;margin: 26upx auto;"></image>
						</view>
						<view class="uni-media-list-body">
							<view class="uni-media-list-text-top" style="font-size: 28upx;" v-cloak>{{res.address_realname}} {{res.address_mobile}}</view>
							<view class="uni-media-list-text-bottom uni-ellipsis" v-cloak>{{res.address_province}}{{res.address_city}}{{res.address_area}} {{res.addressstreet}} {{res.address_address}}</view>
						</view>
					</view>
				</view>
			</view>
			
		</view>
		<view class="goods" style="background: #fff;">
			<view class="uni-list-cell" hover-class="uni-list-cell-hover" v-for="(value,key) in res.goods" :key="key">
				<view class="uni-media-list">
					<view class="uni-media-list-logo" style="width: 160upx;height: 160upx;">
						<image :src="value.thumb" style="width: 160upx;height: 160upx;" ></image>
					</view>
					<view class="uni-media-list-body" style="height: 160upx;">
						<view class="uni-media-list-text-top" style="font-size: 28upx;" v-cloak>{{value.title}}</view>
						<view class="uni-media-list-text-bottom uni-ellipsis" v-cloak>{{value.optiontitle}}</view>
					</view>
				</view>
			</view>
			
		</view>
		<view class="webkit" style="padding: 12upx 24upx;background: #fff;margin-bottom: 20upx;">
			<view class="flex">运费</view>
			<view v-cloak>¥{{res.dispatchprice}}</view>
		</view>
		<view class="detail">
			<view><text>订单编号</text><text v-cloak>{{res.ordersn}}</text></view>
			<view><text>创建时间</text><text v-cloak>{{res.createtime}}</text></view>
			<view v-if="res.status >=1 &&res.paytime >0"><text>支付时间</text><text v-cloak>{{res.paytime}}</text></view>
			<view v-if="res.status >=2||res.status>=1 &&res.sendtype >0"><text>发货时间	</text><text v-cloak>{{res.sendtime}}</text></view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				res:[],
				orderid:0,
				openid:''
			};
		},
		onLoad:function(e){
			uni.showLoading()
			this.orderid = e.id
			uni.getStorage({
				key: 'openid',
				success: (res) => {
					this.openid = res.data
					this.setAjax()
				},
				fail: () => {
					uni.navigateTo({
						url: '../../login/login'
					});
				}
			});
		},methods:{
			setAjax(){
				uni.request({
					url: this.$BASE_URL+'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=order.detail&app=1&id='+this.orderid,
					method: 'POST',
					data: {'openid':this.openid},
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success: res => {
						console.log(res)
						uni.hideLoading()
						this.res = res.data
					},
					fail: () => {},
					complete: () => {}
				});
			},
			jump(){
				uni.navigateTo({
					url: '../express/express?id='+this.orderid
				});
			}
		}
	}
</script>

<style>.top{height:200upx;background:-moz-linear-gradient(left,#ffb43e 0%,#fd9526 100%);background:-webkit-linear-gradient(left,#ffb43e 0%,#fd9526 100%);background:-o-linear-gradient(left,#ffb43e 0%,#fd9526 100%);background:-ms-linear-gradient(left,#ffb43e 0%,#fd9526 100%);background:linear-gradient(to right,#ffb43e 0%,#fd9526 100%);-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;flex-direction:column;align-items:center;-webkit-align-items:center;justify-content:center;padding:0 24upx;font-size:26upx;line-height:48upx;}.top view{color:#fff;font-size:36upx;}.list{margin-bottom:20upx;}.detail view{line-height:40upx;height:40upx;}.detail view text{font-size:24upx;color:#999;}.detail view text:first-child{margin-right:28upx;}.detail{padding:0 24upx;}</style>